<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../common/meta.jsp"%>
<%@ include file="../common/taglibs.jsp"%>
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/easyui/themes/myself/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/easyui/themes/icon.css" />
<script>
function getChecked(){
	var nodes = $('#menuTree').tree('getChecked');
	var s = '';
	for (var i = 0; i < nodes.length; i++) {
	    if (s != '') 
	        s += ';';
	    s += nodes[i].id;
	}
	return s;
}
function saveRoleAuth(roleId) {
	var menuId = getChecked();
	parent.$.messager.progress();
	$.ajax({
		url: 'saveRoleMenuAuth.action',
		data: {roleId:roleId,menuIds:menuId},
		success: function(data) {
			parent.$.messager.progress('close');
			alert('角色授权成功!');
		}
	});
	
}
$(function() {
	$("#menuTree").tree({
		animate: true		
	});
});
</script>
</head>
<body class="easyui-layout">
	<div data-options="region:'center',fit:true,border:false"
		style="padding: 5 5 0 5px; background: #edf7ff">
		${menuTree}
	</div>
	<div data-options="region:'south',border:false"
		style="padding: 5 5 0 5px; background: #edf7ff">
		<input type="button" value="保存" class="easyui-linkbutton"
			onclick="saveRoleAuth('${roleId}');" />
		<input type="button" value="重置" class="easyui-linkbutton"
			onclick="location='menuAuth.action?roleId=${roleId}'" />
	</div>
</body>
</html>